package com.yunhe.transfer.client;

import com.yunhe.common.model.authority.Station;
import com.yunhe.transfer.client.fallback.AuthorityFallbackFactory;
import com.yunhe.common.model.ResultObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Component
@FeignClient(value = "yh-authority", fallbackFactory = AuthorityFallbackFactory.class)
public interface AuthorityClient {

    @RequestMapping(value = "/stationForTransfer/getStations", method = RequestMethod.GET)
    ResultObject<List<Station>> getStations(@RequestParam("userId") Long userId);

    @RequestMapping(value = "/stationForTransfer/{id}", method = RequestMethod.GET)
    ResultObject<Station> getStationById(@PathVariable("id") Long stationId);

    /**
     * 根据电站代码获得电站
     * @param code 电站代码
     */
    @RequestMapping(value = "/stationForTransfer/byCode", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Station>> getStationByCode(@RequestParam("code") Long code);
}
